<template>
  <div>
    <h1>父组件</h1>
     <h1>父组件</h1>
      <h1>父组件</h1>
       <h1>父组件</h1>
        <h1>父组件</h1>
         <h1>父组件</h1>
    <!-- 父组件挂载之后执行回调函数渲染子组件 -->
    <child-component v-if="isParentReady" :totalData="totalData"></child-component>
  </div>
</template>

<script>
import ChildComponent from "./ChildrenComponent.vue";
import axios from 'axios';
export default {
    components:{
     ChildComponent,
    },
    data() {
        return {
            isParentReady: false,
            totalData: null,
        };
    },
    methods: {
        initData() {
          axios.get('/api/goods/projectList').then(response => {
            this.totalData = response.data;
            console.log('Fetched data:', this.totalData);
          }).catch(error => {
            console.error('Error fetching data:', error);
          });
        }
    },
    mounted() {
        // 查询接口
        this.initData();
        // 模拟父组件挂载后的操作
        // setTimeout(() => {
        // this.isParentReady = true;
        // this.$nextTick(() => {
        //     console.log("子组件已经渲染");
        // });
        // }, 1000);
    }
};
</script>
<style scoped>  
</style>